// name-change
import { UserInfoEditMixins, UserInfoUpdateMixins } from '../../../../behaviors/page';
import { tipToast } from '../../../../common/env';

Page({
    mixins: [UserInfoEditMixins, UserInfoUpdateMixins],
    data: {
        name: '',
    },
    onLoad: function (options) {
        this.setData({
            name: this.data.userInfo.nickName,
        });
    },
    onNameChange: function (event) {
        this.setData({
            name: event.detail,
        });
    },
    // 保存名称
    saveName: async function () {
        const { name } = this.data;
        if (!name) {
            tipToast('请输入昵称');
            return;
        }
        await this.userInfoUpdataAction({
            nickName: name,
        });
    },
})